﻿@model JuCheap.Models.MenuDto

@{
    ViewBag.Title = "添加菜单";
    Layout = "~/Views/Shared/_Layout_Content.cshtml";
}

<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>@ViewBag.Title</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
           @using (Ajax.BeginForm("AddAjax", "Menu", null, new AjaxOptions { HttpMethod = "POST", OnSuccess = "onSuccess"}, new { id = "postForm", @class = "form-horizontal" }))
           {
                <div class="form-group">
                    <label class="col-sm-3 control-label">@Html.LabelFor(m => m.ParentName)：</label>
                    <div class="col-sm-8">

                        <div class="input-group">
                            @Html.TextBoxFor(m => m.ParentName, new { @class = "form-control", placeholder = "上级菜单" })
                            @Html.HiddenFor(m => m.ParentId)
                            @Html.ValidationMessageFor(m => m.ParentName)
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-white dropdown-toggle" data-toggle="dropdown">
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-right" role="menu"></ul>
                            </div>
                            <!-- /btn-group -->
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">@Html.LabelFor(m => m.Name)：</label>
                    <div class="col-sm-8">
                        @Html.TextBoxFor(m => m.Name, new { @class = "form-control", placeholder = "菜单名称" })
                        @Html.ValidationMessageFor(m => m.Name)
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">@Html.LabelFor(m => m.Url)：</label>
                    <div class="col-sm-8">
                        @Html.TextBoxFor(m => m.Url, new { @class = "form-control", placeholder = "URL地址" })
                        @Html.ValidationMessageFor(m => m.Url)
                    </div>
                </div>
               <div class="form-group">
                   <label class="col-sm-3 control-label">@Html.LabelFor(m => m.Order)：</label>
                   <div class="col-sm-8">
                       @Html.TextBoxFor(m => m.Order, new {@class = "form-control", placeholder = "排序"})
                       @Html.ValidationMessageFor(m => m.Order)
                   </div>
               </div>
                <div class="form-group">
                    <label class="col-sm-3 control-label">@Html.LabelFor(m => m.Icon)：</label>
                    <div class="col-sm-8">
                        @Html.TextBoxFor(m => m.Icon, new { @class = "form-control", placeholder = "图标" })
                        @Html.ValidationMessageFor(m => m.Icon)
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-offset-3 col-sm-8">
                        <button class="btn btn-info" type="submit" id="btnSave">保存</button>
                        <button class="btn btn-white" type="button" id="btnBack">关闭</button>
                    </div>
                </div>
            }
        </div>
    </div>
</div>
@section scripts{
    @Scripts.Render("~/content/js/jqueryValidate", "~/bundles/jqueryAjax", "~/content/js/menu", "~/content/js/action")
    <script>
        function onSuccess(res) {
            if (res && res.flag) {
                $("#btnSave").button("reset");
                parent.layer.msg("添加成功,新菜单的Id=" + res.data);
            } else {
                parent.layer.msg("添加失败");
            }
        }
        $(function() {
            $("#btnBack").click(function() {
                parent.layer.closeAll();
            });
        })
    </script>
}
